; +---------------------------------------------------------------------+
; |  Chamada:	CALL	GetVariable                                     | 
; |                                                                     |
; |  Definir as seguintes variaveis no segmento de dados .DATA:         |
; |                                                                     |
; |  varX	DW	?                                               |
; |  varS	DB	?                                               |
; +---------------------------------------------------------------------+

GetVariable	PROC	NEAR

		PUSH	ESI

		MOV	ESI,DWORD PTR [EBX+12]
		ADD	ESI,4
		MOV	varX,0

SearchVariable:
		CMP	BYTE PTR [ESI],0
		JE	NewVariable
		MOV	EAX,DWORD PTR value[0]
		CMP	EAX,DWORD PTR [ESI+0]
		JNE	SearchNextVariable
		MOV	EAX,DWORD PTR value[4]
		CMP	EAX,DWORD PTR [ESI+4]
		JNE	SearchNextVariable
		MOV	EAX,DWORD PTR value[8]
		CMP	EAX,DWORD PTR [ESI+8]
		JNE	SearchNextVariable
		MOV	EAX,DWORD PTR value[12]
		CMP	EAX,DWORD PTR [ESI+12]
		JNE	SearchNextVariable

OldVariable:
		MOV	AL,BYTE PTR [ESI+24]
		MOV	varS,AL
		POP	ESI

		RET

SearchNextVariable:
		ADD	ESI,25
		INC	varX
		JMP	SearchVariable

NewVariable:
		MOV	EAX,DWORD PTR value[0]
		MOV	DWORD PTR [ESI+0],EAX
		MOV	EAX,DWORD PTR value[4]
		MOV	DWORD PTR [ESI+4],EAX
		MOV	EAX,DWORD PTR value[8]
		MOV	DWORD PTR [ESI+8],EAX
		MOV	EAX,DWORD PTR value[12]
		MOV	DWORD PTR [ESI+12],EAX
		FLDZ
		FSTP	QWORD PTR [ESI+16]
		MOV	BYTE PTR [ESI+24],-2

		MOV	varS,-2
		MOV	rC,22

		MOV	ESI,DWORD PTR [EBX+12]
		INC	DWORD PTR [ESI]
		POP	ESI

		RET

		ENDP
